package com.thread.threadpractice.mapper;

import com.thread.threadpractice.entity.Product;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ProductMapper {

    @Select("select * from product")
    List<Product> selectAll();

    @Insert({
            "<script>",
            "INSERT INTO product (title, images, description, sale_num, price, favorite_num, category_id, update_time, create_time, is_deleted) VALUES ",
            "<foreach collection='list' item='item' separator=','>",
            "(#{item.title}, #{item.images}, #{item.description}, #{item.saleNum}, #{item.price}, #{item.favoriteNum}, #{item.categoryId}, #{item.updateTime}, #{item.createTime}, #{item.isDeleted})",
            "</foreach>",
            "</script>"
    })
    int batchInsert(List<Product> list);
}
